package com.joysuch.wwyt.risk.enums;

/**
 * @Author ZhaoQiuWei
 * @Date 2021/9/1 11:31
 */
public enum ControlStatus {
    YI_FEN_PEI(1, "未分配"),
    WEI_FEN_PEI(2, "已分配");

    private int code;
    private String name;

    private ControlStatus(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public int getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static ControlStatus valueOf(int code) {
        ControlStatus[] values = ControlStatus.values();
        for (ControlStatus r : values) {
            if (r.getCode() == code) {
                return r;
            }
        }
        return null;
    }

    public static String findNameByCode(Integer code) {
        if (code == null) {
            return null;
        }
        ControlStatus of = valueOf(code);
        return of == null ? null : of.getName();
    }

    public static ControlLevels findByName(String name) {
        if (name == null) {
            return null;
        }
        ControlLevels[] values = ControlLevels.values();
        for (ControlLevels r : values) {
            if (r.getName().equals(name)) {
                return r;
            }
        }
        return null;
    }

}
